#include "CardInfo.h"
#include <cstring>
#include "CupSprite.h"

#define cardPath "Cards/card"

CardInfo::CardInfo()
{
}

CardInfo::~CardInfo()
{
}

char* CardInfo::buf;
int CardInfo::s_key[4] = {};

vector<int> CardInfo::getCardKeys(int cardID)
{
    vector<int> rgKeys;
    
	switch (cardID)
	{
		case 0:
		{
			rgKeys = { black, yellow, blue, red, green };
			break;
		}
		case 1:
		{
			rgKeys = { blue, green, black, red, yellow };
			break;
		}
		case 2:
		{
            rgKeys = { yellow, blue, green, red, black };
            break;
		}
		case 3:
		{
            rgKeys = { red, green, black, blue, yellow };
            break;
		}
		case 4:
		{
            rgKeys = { black, green, red, blue, yellow };
            break;
		}
		case 5:
		{
            rgKeys = { yellow, green, red, blue, black };
            break;
		}
		case 6:
		{
            rgKeys = { green, black, yellow, red, blue };
            break;
		}
		case 7:
		{
            rgKeys = { green, black, blue, yellow, red };
            break;
		}
		case 8:
		{
            rgKeys = { black, green, red, blue, yellow };
            break;
		}
		case 9:
		{
          rgKeys = { yellow, black, blue, red, green };
          break;
		}
		case 10:
		{
          rgKeys = { yellow, blue, red, black, green };
          break;
		}
		case 11:
		{
          rgKeys = { green, black, red, blue, yellow };
          break;
		}
		case 12:
		{
          rgKeys = { blue, yellow, black, red, green };
          break;
		}
		case 13:
		{
          rgKeys = { black, yellow, blue, green, red };
          break;
		}
		case 14:
		{
          rgKeys = { blue, red, yellow, black, green };
          break;
		}
		case 15:
		{
          rgKeys = { green, yellow, black, blue, red };
          break;
		}
		case 16:
		{
          rgKeys = { red, blue, yellow, green, black };
          break;
		}
		case 17:
		{
          rgKeys = { yellow, green, red, black, blue };
          break;
		}
		case 18:
		{
          rgKeys = { red, blue, yellow, green, black };
          break;
		}
		case 19:
		{
          rgKeys = { yellow, green, red, black, blue };
          break;
		}
		case 20:
		{
           rgKeys = { green, black, blue, red, yellow };
           break;
		}
		case 21:
		{
           rgKeys = { red, green, yellow, black, blue };
           break;
		}
		case 22:
		{
           rgKeys = { blue, red, green, black, yellow };
           break;
		}
		case 23:
		{
           rgKeys = { blue, black, green, yellow, red };
           break;
		}
		default:
		{
			return rgKeys;
		}
	}

	return rgKeys;
}

string CardInfo::getCardImage(int cardID)
{
    __String* pStrPath = __String::createWithFormat("Cards/card%02d.png", cardID);
    string strFile = pStrPath->getCString();
    return strFile;
    
//    char imagePath[100];
//    sprintf(imagePath,"%02d.png",cardID);
//
//    int len = strlen(imagePath) + strlen(cardPath);
//
//    if (buf != NULL)
//    {
//        delete []buf;
//        buf = NULL;
//    }
//
//    buf = new char[len + 1];
//    buf[len] = '\0';
//
//    strcpy(buf, cardPath);
//    strcat(buf, imagePath);
//
//    return buf;
}

string CardInfo::getCardBackImage(bool isCross)
{
    string strFile = isCross ? "Cards/card_back1.png" : "Cards/card_back0.png";
    return strFile;
    
//    char imagePath[100];
//    sprintf(imagePath, "_back%d.png", direction);
//
//    int len = strlen(imagePath) + strlen(cardPath);
//
//    if (buf != NULL)
//    {
//        delete[]buf;
//        buf = NULL;
//    }
//
//    buf = new char[len + 1];
//    buf[len] = '\0';
//
//    strcpy(buf, cardPath);
//    strcat(buf, imagePath);
//
//    return buf;
}
